<template>
	<view>
		<view class="lxr_con_list" v-for="(item,index) in contract_list" :key="index"
			@click="toContractDetail(item.id)">
			<view class="name">{{item.name}}</view>
			<view class="info">已回款 &yen;{{item.receivables.repayment_money}}</view>
			<view class="info">待回款 &yen;{{item.receivables.be_money}}</view>
			<view class="proce_li">
				<view class="pro_li_left">
					<view class="protext">回款进度：</view>
					<view class="probox">
						<view class="proin"
							:style="{width:(item.receivables.ratio >= 100 ? 100 : item.receivables.ratio) +'%'}">
						</view>
					</view>
					<view class="pronum">{{item.receivables.ratio}}%</view>
				</view>
				<view class="pro_li_right">&yen;{{item.receivables.be_money}}</view>
			</view>
			<view class="info">签约时间：{{item.order_date}}</view>
			<view class="con_status" v-if="item.check_status == 0">
				<span>待审核</span>
			</view>
			<view class="con_status" v-if="item.check_status == 1">
				<span>审核中</span>
			</view>
			<view class="con_status pass" v-if="item.check_status == 2">
				<span>审核通过</span>
			</view>
			<view class="con_status nopass" v-if="item.check_status == 3">
				<span>审核未通过</span>
			</view>
			<view class="con_status nopass" v-if="item.check_status == 4">
				<span>已撤回</span>
			</view>
		</view>
		<view style="height:200rpx"></view>
		<u-empty v-if="contract_list.length == 0" text="暂无更多"></u-empty>
		<view class="icon_creat" v-if="type == 1" @click="addContract">
			<image :src="BASE_IMG_URL+'1.png'" mode="scaleToFill"></image>
		</view>
	</view>
</template>

<script> 
	import {
		netCrmContractList,
		netSearchStaffList
	} from '@/api/kehu.js'
	import {
		BASE_IMG_URL
	} from '@/util/api.js'

	export default {
		data() {
			return {
				BASE_IMG_URL:BASE_IMG_URL,
				contract_list: [
					//测试数据后删除
					{
					name:'name',
					receivables:[
						{
							repayment_money:'repayment_money',
							ratio:'ratio',
							be_money:'be_money',
						}
					],
					order_date:'order_date',
					check_status:0
					}
				],
				page: 1,
				limit: 10,
				totalPage: 1,
				showSearch: false,
				name: '',
				type: '', //客户分类  '0 全部客户','1 我的客户','2 下属负责的客户'
				typeIndex: 0,
				start_time: '',
				end_time: '',
				ascripList: [], //归属人
				ascripId: null,
				ascripIndex: null,
				info: 0,
				rSelect: [],
				type:1,   //1普通客户  2公海客户
				// id:'',
				customer_id:''
			}
		},
		onLoad(options) {
			if (options.startTime) {
				this.typeIndex = options.type == 0 ? 1 : options.type == 1 ? 0 : 2
				this.type = this.typeList[this.typeIndex]
				this.start_time = options.startTime
				this.end_time = options.endTime
				this.ascripId = options.staffid
			}
			this.id = options.id
			this.type = options.type
		},
		onShow() {
			this.contract_list = []
			this.page = 1
			this.getList()
		},
		onReachBottom() {
			if (this.page >= this.totalPage) {
				return
			}
			this.page++
			this.getList()
		},
		methods: {
			//新增合同
			addContract() {
				uni.navigateTo({
					url: '/pagesA/crm/contract/contract?id='+this.id
				})
			},
			tab(index) {
				this.info = index
			},
			changeAscrip(e) {
				this.ascripIndex = e.detail.value
				this.ascripId = this.ascripList[this.ascripIndex]
			},
			getList() {
				let params = {
					page: this.page,
					limit: this.limit,
					createtime: (this.start_time && this.end_time) ? (this.start_time + ',' + this.end_time) : '',
					type: this.typeIndex,
					staff_id: this.ascripId
				}
				
				
				netCrmContractList({customer_id:this.id}).then(res => {
					this.contract_list = this.contract_list.concat(res.data.data)
					this.totalPage = res.data.last_page
					
				})
				
			},
			//客户分类
			changeType(e) {
				this.typeIndex = e.detail.value
				this.type = this.typeList[e.detail.value]
			},
			//线索创建  开始时间
			changeStartTime(e) {
				this.start_time = e.detail.value
			},
			//线索 创建  结束时间
			changeEndTime(e) {
				this.end_time = e.detail.value
			},
			
			//合同详情
			toContractDetail(id) {
				uni.navigateTo({
					url: '/pages/index/groupCompany/contract/contractDetail?id=' + id
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.active {
		
		text-align: center;
		border: none;
		background: #03AA96;
		padding: 5rpx 10rpx ;
		border-radius: 10rpx;
		color: #FFFFFF;
	}

	.list-box {
		// 　　　　width: 100%;
		overflow: hidden;
		white-space: nowrap;
	}
	.list-box {
		// 　　　　width: 100%;
		overflow: hidden;
		white-space: nowrap;
	}

	.list-item {
		border: 1px solid #999;
		// color: #999;
		padding: 5rpx 10rpx ;border-radius: 10rpx;
	}

	.valueactive {
		color: #666;
	}

	.select_warp {
		z-index: 9;
	}

	.searchbox {
		display: flex;
		justify-content: flex-end;
		margin: 20rpx 0;
		background: #ffffff;
		height: 100rpx;

		.searchtext {
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 30rpx;
			color: #999;
			margin-right: 55rpx;
		}
	}

	.warpbox {
		position: fixed;
		width: 750rpx;
		left: 0;
		top: 0rpx;
		bottom: 0;
		z-index: 2;
		background: rgba(0, 0, 0, 0.7);

		.screen_content {
			width: 702rpx;
			z-index: 2;
			border-top: 1rpx solid #CCCCCC;
			background-color: #fff;
			padding: 24rpx;

			.fir_li {
				margin-bottom: 20rpx;

				.li_label {
					font-size: 28rpx;
					color: #03AA96;
					margin-top: 30rpx;
					margin-bottom: 20rpx;
				}

				.classify {
					// background: red;
					display: flex;
					justify-content: space-around;

					.classify_flex {
						padding: 5rpx 16rpx;
						color: #999;
						font-size: 30rpx;
						border: 1px solid #999;
						border-radius: 10rpx;
					}

					.c_f {
						background: #03AA96 !important;
						color: #fff;
					}
				}

				.li_box {
					// width:700rpx;
					
					height: 60rpx;
					padding: 0 35rpx;
					line-height: 60rpx;
					display: flex;
					justify-content: space-around;
					color: #999;
					
				}

				.form_right {
					// display: flex;
					color: #999;
					text-align: center;

					// justify-content: space-between;
					image {
						width: 40rpx;
						height: 40rpx;
						margin: 28rpx 5rpx 0 0;
					}

				}
			}
		}

		.button_bottom {
			display: flex;
			width: 100%;
			height: 90rpx;
			background-color: #fff;
			line-height: 90rpx;
			text-align: center;
			font-size: 32rpx;
			justify-content: space-around;
			padding-bottom: 100rpx;

			:first-child {
				color: #999;
				border: 1rpx solid #999;
				width: 260rpx;
				height: 88rpx;
				line-height: 88rpx;
				border-radius: 30rpx;
			}

			:last-child {
				background-color: #03AA96;
				color: #fff;
				width: 260rpx;
				height: 88rpx;
				line-height: 88rpx;
				border-radius: 30rpx;
			}
		}
	}

	.lxr_con_list {
		padding: 20rpx 0;
		margin-bottom: 20rpx;
		background: #fff;
		margin-top: 20rpx;
		&:last-child {
			border-bottom: none;
		}

		.name {
			font-size: 34rpx;
			color: #333333;
			// margin-top: 15rpx;
			font-weight: 500;
			border-bottom: 1rpx solid #ededed;
			padding: 0 0 30rpx 63rpx;
		}

		.info {
			font-size: 32rpx;
			color: #999999;
			margin: 10rpx 0;
			padding-left: 63rpx;
		}

		.proce_li {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding-left: 63rpx;
			margin: 10rpx 0;

			.pro_li_left {
				display: flex;
				justify-content: flex-start;
				align-items: center;

				.protext {
					font-size: 32rpx;
					color: #999999;
				}

				.probox {
					width: 120rpx;
					height: 30rpx;
					border-radius: 15rpx;
					background: #C0C0C0;
					margin: 0 15rpx;

					.proin {
						width: 20%;
						height: 30rpx;
						border-radius: 15rpx;
						background: #03AA96;
					}
				}

				.pronum {
					font-size: 24rpx;
					color: #999999;
				}
			}

			.pro_li_right {
				color: #03AA96;
				font-size: 40rpx;
				font-weight: 500;
				margin-right: 28rpx;
			}
		}

		.con_status {
			width: 130rpx;
			height: 36rpx;
			text-align: center;
			line-height: 36rpx;
			background: rgba(3, 170, 150, .1);
			margin-top: 30rpx;
			margin-left: 63rpx;

			span {
				font-size: 26rpx;
				color: #03AA96;


			}
		}

		.nopass {
			color: #ec7f51;
		}

		.pass {
			color: #22A7F6;
		}
		
	}
	#btn{
			width: 500rpx;
			height: 88rpx;
			background: #03AA96;
			border-radius: 29rpx;
			font-size: 34rpx;
			color: #fff;
			line-height: 88rpx;
		}
</style>
